import { Injectable } from '@nestjs/common';
import { parse } from "node-xlsx"

@Injectable()
export class BasicService {

    public async xlsx2data(files) {
        const result = [];
        for (const { buffer, fieldname } of files) {
            const xlsx = parse(buffer);
            for (const { name, data } of xlsx) {
                for (let i = 0; i < data.length; i++) {
                    const line = data[i];
                    result.push(line)
                }
            }
        }
        return result;
    }
}
